﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Beetle.Sl.EditorControl.Core;
using System.IO;

namespace Beetle.Sl.EditorControl.Commands
{
    [CommandAttribute]
    public class OpenLocalFileDocCommand : DocCommand
    {
        public override string CommandText
        {
            get
            {
                return "OpenLocalFile";
            }
        }

        public override void Excute(object parameter)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();
            openFileDialog.Filter = "Rich xaml Files | *.rich";
            openFileDialog.Multiselect = false;

            if (openFileDialog.ShowDialog() == true)
            {
                if (openFileDialog.File != null)
                {
                    FileStream fileStream = openFileDialog.File.OpenRead();
                    byte[] bytes = new byte[fileStream.Length];
                    fileStream.Read(bytes, 0, bytes.Length);
                    fileStream.Close();

                    this.Editor.SetZipBytes(bytes);
                }
            }
        }
    }
}
